package o;

import android.animation.Animator;
import android.animation.Animator.AnimatorListener;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Matrix;
import android.graphics.Matrix.ScaleToFit;
import android.graphics.PorterDuff.Mode;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.LayerDrawable;
import android.os.Build.VERSION;
import android.view.View;
import android.view.ViewTreeObserver.OnPreDrawListener;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.view.ViewCompat;
import com.google.android.material.internal.VisibilityAwareImageButton;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class arq {
    static final int[] ʻॱ = new int[]{16843623, 16842908, 16842910};
    static final int[] ʾ = new int[0];
    static final TimeInterpolator ˋ = aqv.ˏ;
    static final int[] ॱˋ = new int[]{16842910};
    static final int[] ॱˎ = new int[]{16842908, 16842910};
    static final int[] ॱᐝ = new int[]{16842919, 16842910};
    static final int[] ᐝॱ = new int[]{16843623, 16842910};
    art ʻ;
    asn ʼ;
    final ask ʼॱ;
    Drawable ʽ;
    @Nullable
    private aqz ʽॱ;
    final VisibilityAwareImageButton ʿ;
    @Nullable
    private aqz ˈ;
    private float ˉ;
    @Nullable
    aqz ˊ;
    private final ase ˊˊ;
    private final Rect ˊˋ = new Rect();
    int ˊॱ;
    private ArrayList<AnimatorListener> ˊᐝ;
    private ArrayList<AnimatorListener> ˋˊ;
    private final RectF ˋˋ = new RectF();
    float ˋॱ;
    private OnPreDrawListener ˋᐝ;
    private final Matrix ˌ = new Matrix();
    @Nullable
    Animator ˎ;
    private final RectF ˎˎ = new RectF();
    @Nullable
    aqz ˏ;
    float ˏॱ;
    float ͺ = 1.0f;
    int ॱ = 0;
    float ॱˊ;
    Drawable ॱॱ;
    Drawable ᐝ;

    public interface c {
        void ˊ();

        void ˋ();
    }

    abstract class f extends AnimatorListenerAdapter implements AnimatorUpdateListener {
        private float ˊ;
        final /* synthetic */ arq ˎ;
        private boolean ˏ;
        private float ॱ;

        protected abstract float ˏ();

        private f(arq o_arq) {
            this.ˎ = o_arq;
        }

        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            if (!this.ˏ) {
                this.ॱ = this.ˎ.ʼ.ˏ();
                this.ˊ = ˏ();
                this.ˏ = true;
            }
            this.ˎ.ʼ.ॱ(this.ॱ + ((this.ˊ - this.ॱ) * valueAnimator.getAnimatedFraction()));
        }

        public void onAnimationEnd(Animator animator) {
            this.ˎ.ʼ.ॱ(this.ˊ);
            this.ˏ = false;
        }
    }

    class a extends f {
        final /* synthetic */ arq ˊ;

        a(arq o_arq) {
            this.ˊ = o_arq;
            super();
        }

        protected float ˏ() {
            return 0.0f;
        }
    }

    class b extends f {
        final /* synthetic */ arq ˏ;

        b(arq o_arq) {
            this.ˏ = o_arq;
            super();
        }

        protected float ˏ() {
            return this.ˏ.ˏॱ;
        }
    }

    class d extends f {
        final /* synthetic */ arq ॱ;

        d(arq o_arq) {
            this.ॱ = o_arq;
            super();
        }

        protected float ˏ() {
            return this.ॱ.ˏॱ + this.ॱ.ˋॱ;
        }
    }

    class e extends f {
        final /* synthetic */ arq ˋ;

        e(arq o_arq) {
            this.ˋ = o_arq;
            super();
        }

        protected float ˏ() {
            return this.ˋ.ˏॱ + this.ˋ.ॱˊ;
        }
    }

    public arq(VisibilityAwareImageButton visibilityAwareImageButton, ask o_ask) {
        this.ʿ = visibilityAwareImageButton;
        this.ʼॱ = o_ask;
        this.ˊˊ = new ase();
        this.ˊˊ.ˏ(ॱᐝ, ˎ(new d(this)));
        this.ˊˊ.ˏ(ʻॱ, ˎ(new e(this)));
        this.ˊˊ.ˏ(ॱˎ, ˎ(new e(this)));
        this.ˊˊ.ˏ(ᐝॱ, ˎ(new e(this)));
        this.ˊˊ.ˏ(ॱˋ, ˎ(new b(this)));
        this.ˊˊ.ˏ(ʾ, ˎ(new a(this)));
        this.ˉ = this.ʿ.getRotation();
    }

    public void ˊ(ColorStateList colorStateList, Mode mode, ColorStateList colorStateList2, int i) {
        Drawable[] drawableArr;
        this.ॱॱ = gg.ʻ(ॱˊ());
        gg.ॱ(this.ॱॱ, colorStateList);
        if (mode != null) {
            gg.ˋ(this.ॱॱ, mode);
        }
        this.ᐝ = gg.ʻ(ॱˊ());
        gg.ॱ(this.ᐝ, asl.ˎ(colorStateList2));
        if (i > 0) {
            this.ʻ = ˎ(i, colorStateList);
            drawableArr = new Drawable[]{this.ʻ, this.ॱॱ, this.ᐝ};
        } else {
            this.ʻ = null;
            drawableArr = new Drawable[]{this.ॱॱ, this.ᐝ};
        }
        this.ʽ = new LayerDrawable(drawableArr);
        this.ʼ = new asn(this.ʿ.getContext(), this.ʽ, this.ʼॱ.ˎ(), this.ˏॱ, this.ˏॱ + this.ˋॱ);
        this.ʼ.ˋ(false);
        this.ʼॱ.ॱ(this.ʼ);
    }

    public void ˋ(ColorStateList colorStateList) {
        if (this.ॱॱ != null) {
            gg.ॱ(this.ॱॱ, colorStateList);
        }
        if (this.ʻ != null) {
            this.ʻ.ˏ(colorStateList);
        }
    }

    public void ˏ(Mode mode) {
        if (this.ॱॱ != null) {
            gg.ˋ(this.ॱॱ, mode);
        }
    }

    public void ˊ(ColorStateList colorStateList) {
        if (this.ᐝ != null) {
            gg.ॱ(this.ᐝ, asl.ˎ(colorStateList));
        }
    }

    public final void ˎ(float f) {
        if (this.ˏॱ != f) {
            this.ˏॱ = f;
            ॱ(this.ˏॱ, this.ॱˊ, this.ˋॱ);
        }
    }

    float ˋ() {
        return this.ˏॱ;
    }

    public final void ˋ(float f) {
        if (this.ॱˊ != f) {
            this.ॱˊ = f;
            ॱ(this.ˏॱ, this.ॱˊ, this.ˋॱ);
        }
    }

    public final void ˊ(float f) {
        if (this.ˋॱ != f) {
            this.ˋॱ = f;
            ॱ(this.ˏॱ, this.ॱˊ, this.ˋॱ);
        }
    }

    public final void ˎ(int i) {
        if (this.ˊॱ != i) {
            this.ˊॱ = i;
            ˊ();
        }
    }

    public final void ˊ() {
        ˏ(this.ͺ);
    }

    final void ˏ(float f) {
        this.ͺ = f;
        Matrix matrix = this.ˌ;
        ॱ(f, matrix);
        this.ʿ.setImageMatrix(matrix);
    }

    private void ॱ(float f, Matrix matrix) {
        matrix.reset();
        Drawable drawable = this.ʿ.getDrawable();
        if (drawable != null && this.ˊॱ != 0) {
            RectF rectF = this.ˎˎ;
            RectF rectF2 = this.ˋˋ;
            rectF.set(0.0f, 0.0f, (float) drawable.getIntrinsicWidth(), (float) drawable.getIntrinsicHeight());
            rectF2.set(0.0f, 0.0f, (float) this.ˊॱ, (float) this.ˊॱ);
            matrix.setRectToRect(rectF, rectF2, ScaleToFit.CENTER);
            matrix.postScale(f, f, ((float) this.ˊॱ) / 2.0f, ((float) this.ˊॱ) / 2.0f);
        }
    }

    public final void ˋ(@Nullable aqz o_aqz) {
        this.ˊ = o_aqz;
    }

    public final void ˏ(@Nullable aqz o_aqz) {
        this.ˏ = o_aqz;
    }

    void ॱ(float f, float f2, float f3) {
        if (this.ʼ != null) {
            this.ʼ.ˊ(f, this.ˋॱ + f);
            ॱ();
        }
    }

    public void ॱ(int[] iArr) {
        this.ˊˊ.ˎ(iArr);
    }

    public void ˏ() {
        this.ˊˊ.ˊ();
    }

    public void ˋ(@NonNull AnimatorListener animatorListener) {
        if (this.ˊᐝ == null) {
            this.ˊᐝ = new ArrayList();
        }
        this.ˊᐝ.add(animatorListener);
    }

    public void ॱ(@NonNull AnimatorListener animatorListener) {
        if (this.ˊᐝ != null) {
            this.ˊᐝ.remove(animatorListener);
        }
    }

    public void ˎ(@NonNull AnimatorListener animatorListener) {
        if (this.ˋˊ == null) {
            this.ˋˊ = new ArrayList();
        }
        this.ˋˊ.add(animatorListener);
    }

    public void ˏ(@NonNull AnimatorListener animatorListener) {
        if (this.ˋˊ != null) {
            this.ˋˊ.remove(animatorListener);
        }
    }

    public void ˎ(@Nullable final c cVar, final boolean z) {
        if (!ͺ()) {
            if (this.ˎ != null) {
                this.ˎ.cancel();
            }
            if (ॱˋ()) {
                aqz o_aqz;
                if (this.ˏ != null) {
                    o_aqz = this.ˏ;
                } else {
                    o_aqz = ʻॱ();
                }
                AnimatorSet ˊ = ˊ(o_aqz, 0.0f, 0.0f, 0.0f);
                ˊ.addListener(new AnimatorListenerAdapter(this) {
                    final /* synthetic */ arq ˎ;
                    private boolean ˏ;

                    public void onAnimationStart(Animator animator) {
                        this.ˎ.ʿ.ˋ(0, z);
                        this.ˎ.ॱ = 1;
                        this.ˎ.ˎ = animator;
                        this.ˏ = false;
                    }

                    public void onAnimationCancel(Animator animator) {
                        this.ˏ = true;
                    }

                    public void onAnimationEnd(Animator animator) {
                        this.ˎ.ॱ = 0;
                        this.ˎ.ˎ = null;
                        if (!this.ˏ) {
                            this.ˎ.ʿ.ˋ(z ? 8 : 4, z);
                            if (cVar != null) {
                                cVar.ˋ();
                            }
                        }
                    }
                });
                if (this.ˋˊ != null) {
                    Iterator it = this.ˋˊ.iterator();
                    while (it.hasNext()) {
                        ˊ.addListener((AnimatorListener) it.next());
                    }
                }
                ˊ.start();
                return;
            }
            this.ʿ.ˋ(z ? 8 : 4, z);
            if (cVar != null) {
                cVar.ˋ();
            }
        }
    }

    public void ˋ(@Nullable final c cVar, final boolean z) {
        if (!ˊॱ()) {
            if (this.ˎ != null) {
                this.ˎ.cancel();
            }
            if (ॱˋ()) {
                aqz o_aqz;
                if (this.ʿ.getVisibility() != 0) {
                    this.ʿ.setAlpha(0.0f);
                    this.ʿ.setScaleY(0.0f);
                    this.ʿ.setScaleX(0.0f);
                    ˏ(0.0f);
                }
                if (this.ˊ != null) {
                    o_aqz = this.ˊ;
                } else {
                    o_aqz = ˋॱ();
                }
                AnimatorSet ˊ = ˊ(o_aqz, 1.0f, 1.0f, 1.0f);
                ˊ.addListener(new AnimatorListenerAdapter(this) {
                    final /* synthetic */ arq ॱ;

                    public void onAnimationStart(Animator animator) {
                        this.ॱ.ʿ.ˋ(0, z);
                        this.ॱ.ॱ = 2;
                        this.ॱ.ˎ = animator;
                    }

                    public void onAnimationEnd(Animator animator) {
                        this.ॱ.ॱ = 0;
                        this.ॱ.ˎ = null;
                        if (cVar != null) {
                            cVar.ˊ();
                        }
                    }
                });
                if (this.ˊᐝ != null) {
                    Iterator it = this.ˊᐝ.iterator();
                    while (it.hasNext()) {
                        ˊ.addListener((AnimatorListener) it.next());
                    }
                }
                ˊ.start();
                return;
            }
            this.ʿ.ˋ(0, z);
            this.ʿ.setAlpha(1.0f);
            this.ʿ.setScaleY(1.0f);
            this.ʿ.setScaleX(1.0f);
            ˏ(1.0f);
            if (cVar != null) {
                cVar.ˊ();
            }
        }
    }

    private aqz ˋॱ() {
        if (this.ʽॱ == null) {
            this.ʽॱ = aqz.ˏ(this.ʿ.getContext(), o.aqu.e.ˎ);
        }
        return this.ʽॱ;
    }

    private aqz ʻॱ() {
        if (this.ˈ == null) {
            this.ˈ = aqz.ˏ(this.ʿ.getContext(), o.aqu.e.ˊ);
        }
        return this.ˈ;
    }

    @NonNull
    private AnimatorSet ˊ(@NonNull aqz o_aqz, float f, float f2, float f3) {
        List arrayList = new ArrayList();
        Animator ofFloat = ObjectAnimator.ofFloat(this.ʿ, View.ALPHA, new float[]{f});
        o_aqz.ˏ("opacity").ˊ(ofFloat);
        arrayList.add(ofFloat);
        ofFloat = ObjectAnimator.ofFloat(this.ʿ, View.SCALE_X, new float[]{f2});
        o_aqz.ˏ("scale").ˊ(ofFloat);
        arrayList.add(ofFloat);
        ofFloat = ObjectAnimator.ofFloat(this.ʿ, View.SCALE_Y, new float[]{f2});
        o_aqz.ˏ("scale").ˊ(ofFloat);
        arrayList.add(ofFloat);
        ॱ(f3, this.ˌ);
        ofFloat = ObjectAnimator.ofObject(this.ʿ, new aqy(), new ara(), new Matrix[]{new Matrix(this.ˌ)});
        o_aqz.ˏ("iconScale").ˊ(ofFloat);
        arrayList.add(ofFloat);
        AnimatorSet animatorSet = new AnimatorSet();
        aqs.ˏ(animatorSet, arrayList);
        return animatorSet;
    }

    public void ˎ() {
    }

    public final void ॱ() {
        Rect rect = this.ˊˋ;
        ˋ(rect);
        ˎ(rect);
        this.ʼॱ.ˎ(rect.left, rect.top, rect.right, rect.bottom);
    }

    void ˋ(Rect rect) {
        this.ʼ.getPadding(rect);
    }

    void ˎ(Rect rect) {
    }

    public void ʼ() {
        if (ᐝ()) {
            ᐝॱ();
            this.ʿ.getViewTreeObserver().addOnPreDrawListener(this.ˋᐝ);
        }
    }

    public void ʻ() {
        if (this.ˋᐝ != null) {
            this.ʿ.getViewTreeObserver().removeOnPreDrawListener(this.ˋᐝ);
            this.ˋᐝ = null;
        }
    }

    boolean ᐝ() {
        return true;
    }

    art ˎ(int i, ColorStateList colorStateList) {
        Context context = this.ʿ.getContext();
        art ʽ = ʽ();
        ʽ.ˋ(fo.ˋ(context, o.aqu.b.ᐝ), fo.ˋ(context, o.aqu.b.ʽ), fo.ˋ(context, o.aqu.b.ॱॱ), fo.ˋ(context, o.aqu.b.ʻ));
        ʽ.ˊ((float) i);
        ʽ.ˏ(colorStateList);
        return ʽ;
    }

    art ʽ() {
        return new art();
    }

    void ॱॱ() {
        float rotation = this.ʿ.getRotation();
        if (this.ˉ != rotation) {
            this.ˉ = rotation;
            ॱᐝ();
        }
    }

    private void ᐝॱ() {
        if (this.ˋᐝ == null) {
            this.ˋᐝ = new OnPreDrawListener(this) {
                final /* synthetic */ arq ˊ;

                {
                    this.ˊ = r1;
                }

                public boolean onPreDraw() {
                    this.ˊ.ॱॱ();
                    return true;
                }
            };
        }
    }

    GradientDrawable ॱˊ() {
        GradientDrawable ˏॱ = ˏॱ();
        ˏॱ.setShape(1);
        ˏॱ.setColor(-1);
        return ˏॱ;
    }

    GradientDrawable ˏॱ() {
        return new GradientDrawable();
    }

    public boolean ˊॱ() {
        if (this.ʿ.getVisibility() != 0) {
            if (this.ॱ == 2) {
                return true;
            }
            return false;
        } else if (this.ॱ == 1) {
            return false;
        } else {
            return true;
        }
    }

    boolean ͺ() {
        if (this.ʿ.getVisibility() == 0) {
            if (this.ॱ == 1) {
                return true;
            }
            return false;
        } else if (this.ॱ == 2) {
            return false;
        } else {
            return true;
        }
    }

    private ValueAnimator ˎ(@NonNull f fVar) {
        ValueAnimator valueAnimator = new ValueAnimator();
        valueAnimator.setInterpolator(ˋ);
        valueAnimator.setDuration(100);
        valueAnimator.addListener(fVar);
        valueAnimator.addUpdateListener(fVar);
        valueAnimator.setFloatValues(new float[]{0.0f, 1.0f});
        return valueAnimator;
    }

    private boolean ॱˋ() {
        return ViewCompat.ˊᐝ(this.ʿ) && !this.ʿ.isInEditMode();
    }

    private void ॱᐝ() {
        if (VERSION.SDK_INT == 19) {
            if (this.ˉ % 90.0f != 0.0f) {
                if (this.ʿ.getLayerType() != 1) {
                    this.ʿ.setLayerType(1, null);
                }
            } else if (this.ʿ.getLayerType() != 0) {
                this.ʿ.setLayerType(0, null);
            }
        }
        if (this.ʼ != null) {
            this.ʼ.ˋ(-this.ˉ);
        }
        if (this.ʻ != null) {
            this.ʻ.ˎ(-this.ˉ);
        }
    }
}
